home *** CD-ROM | disk | FTP | other *** search
/ Champak 62 / Volume 62 - JOGO DISK .iso / Games / penguin_dinner.swf / scripts / __Packages / classes / ui / DayResult.as < prev    next >
Text File  |  2008-03-17  |  10KB  |  198 lines

  1. class classes.ui.DayResult extends classes.ui.AbstractWidget
  2. {
  3.    function DayResult()
  4.    {
  5.       super();
  6.       this.next_day_btn = this.part.next_day_btn;
  7.       this.upgrades_btn = this.part.upgrades_btn;
  8.       this.continue_btn = this.part.continue_btn;
  9.       this.next_stage_btn = this.part.next_stage_btn;
  10.       this.main_menu_btn = this.part.main_menu_btn;
  11.       this.submit_score_btn = this.part.submit_score_btn;
  12.       this.day_goal_caption = this.part.day_goal_caption;
  13.       this.day_earnings_caption = this.part.day_earnings_caption;
  14.       this.day_profit_caption = this.part.day_profit_caption;
  15.       this.total_profit_caption = this.part.total_profit_caption;
  16.       this.total_earnings_caption = this.part.total_earnings_caption;
  17.       this.day_goal_str = this.part.day_goal_str;
  18.       this.day_earnings_str = this.part.day_earnings_str;
  19.       this.day_profit_str = this.part.day_profit_str;
  20.       this.total_profit_str = this.part.total_profit_str;
  21.       this.total_earnings_str = this.part.total_earnings_str;
  22.       this.day_failed_caption = this.part.day_failed_caption;
  23.       this.day_win_caption = this.part.day_win_caption;
  24.       this.progress_saved_caption = this.part.progress_saved_caption;
  25.       this.day_failed_caption._visible = this.day_win_caption._visible = this.progress_saved_caption._visible = this.day_goal_caption._visible = this.day_earnings_caption._visible = this.day_profit_caption._visible = this.total_profit_caption._visible = this.total_earnings_caption._visible = this.day_goal_str._visible = this.day_earnings_str._visible = this.day_profit_str._visible = this.total_profit_str._visible = this.total_earnings_str._visible = false;
  26.       this.next_day_btn._visible = this.continue_btn._visible = this.next_stage_btn._visible = this.main_menu_btn._visible = this.submit_score_btn._visible = this.upgrades_btn._visible = false;
  27.       this.doLater(this.init);
  28.       classes.core.SoundManager.getInstance().startMusicTrack("splash_screen_track");
  29.    }
  30.    function init()
  31.    {
  32.       this.animator = new classes.core.Animator([this.blinds]);
  33.       this.blinds.animate(["state_close","state_fixed"]);
  34.       this.blinds.addEventListener(classes.movieclip.AnimatedClip.COMPLETE_SEQUENCE,this,"showResult");
  35.       this.startLocalLoop(this.update);
  36.       this.next_day_btn.addEventListener(classes.ui.TextButton.CLICK,this,"onButtonClick");
  37.       this.upgrades_btn.addEventListener(classes.ui.TextButton.CLICK,this,"onButtonClick");
  38.       this.continue_btn.addEventListener(classes.ui.TextButton.CLICK,this,"onButtonClick");
  39.       this.next_stage_btn.addEventListener(classes.ui.TextButton.CLICK,this,"onButtonClick");
  40.       this.main_menu_btn.addEventListener(classes.ui.TextButton.CLICK,this,"onButtonClick");
  41.       this.submit_score_btn.addEventListener(classes.ui.TextButton.CLICK,this,"onButtonClick");
  42.       var _loc2_ = 0;
  43.       while(_loc2_ < 6)
  44.       {
  45.          var _loc3_ = this["tip_btn_" + _loc2_];
  46.          _loc3_.enabled = false;
  47.          _loc3_.onRollOver = ru.inils.utils.ExtDelegate.create(this,this.onTipButtonClick,[_loc2_,_loc3_._y]);
  48.          _loc2_ = _loc2_ + 1;
  49.       }
  50.    }
  51.    function onTipButtonClick($tipIndex, $tipY)
  52.    {
  53.       this.tip._y = $tipY;
  54.       this.tip.show($tipIndex);
  55.    }
  56.    function onButtonClick(e)
  57.    {
  58.       switch(e.target)
  59.       {
  60.          case this.next_day_btn:
  61.             classes.core.Application.getInstance().gotoGameBoard();
  62.             break;
  63.          case this.continue_btn:
  64.             classes.core.Application.getInstance().gotoGameCompletedScreen();
  65.             break;
  66.          case this.next_stage_btn:
  67.             classes.core.Application.getInstance().gotoMapScreen();
  68.             break;
  69.          case this.upgrades_btn:
  70.             this.next_day_btn.lock();
  71.             this.upgrades_btn.lock();
  72.             this.main_menu_btn.lock();
  73.             var _loc2_ = classes.core.WidgetManager.getInstance();
  74.             this.upgradeShop = _loc2_.createWidget(classes.core.WidgetManager.WIDGET_UPGRADE_SHOP,this,1);
  75.             this.upgradeShop.addEventListener(classes.ui.AbstractWidget.DISPOSE,this,"onUpgradeShopDispose");
  76.             break;
  77.          case this.main_menu_btn:
  78.             classes.core.Application.getInstance().gotoToMainMenu();
  79.             break;
  80.          case this.submit_score_btn:
  81.             classes.utils.URLCaller.submitScore(classes.core.SOManager.getInstance().__get__totalScore());
  82.       }
  83.    }
  84.    function onUpgradeShopDispose()
  85.    {
  86.       this.total_profit_str.text = classes.utils.Utils.formattedCurrency(classes.core.SOManager.getInstance().__get__totalProfit());
  87.    }
  88.    function showResult()
  89.    {
  90.       classes.core.Application.getInstance().disposeGameBoard();
  91.       classes.core.WidgetManager.getInstance().unlockAllGlobal();
  92.       var _loc2_ = classes.core.SOManager.getInstance().__get__dayScore() - classes.game.GameData.__get__DAY_GOAL();
  93.       var _loc3_ = classes.utils.Utils.formattedCurrency(_loc2_);
  94.       if(_loc2_ < 0)
  95.       {
  96.          this.main_menu_btn._x = 390;
  97.          this.next_day_btn.__set__label("Restart day");
  98.          this.day_failed_caption._visible = true;
  99.       }
  100.       else
  101.       {
  102.          this.day_win_caption._visible = true;
  103.       }
  104.       classes.core.SOManager.getInstance().totalDaysPlaying = classes.core.SOManager.getInstance().totalDaysPlaying + 1;
  105.       this.localConv = com.potapenko.managers.Conv.create();
  106.       this.localConv.addPause(500);
  107.       this.localConv.put(this.day_goal_caption,"_visible",0,true);
  108.       this.localConv.put(this.day_goal_str,"_visible",0,true);
  109.       this.localConv.put(this.day_goal_str,"text",0,classes.utils.Utils.formattedCurrency(classes.game.GameData.__get__DAY_GOAL()));
  110.       this.localConv.put(this.tip_btn_0,"enabled",0,true);
  111.       this.localConv.put(classes.core.SoundManager.getInstance(),"startSound",0,"message_popup");
  112.       this.localConv.put(this,"showStarEffect",500,this.day_goal_str);
  113.       this.localConv.put(this.day_earnings_caption,"_visible",0,true);
  114.       this.localConv.put(this.day_earnings_str,"_visible",0,true);
  115.       this.localConv.put(this.day_earnings_str,"text",0,classes.utils.Utils.formattedCurrency(classes.core.SOManager.getInstance().__get__dayScore()));
  116.       this.localConv.put(this.tip_btn_1,"enabled",0,true);
  117.       this.localConv.put(classes.core.SoundManager.getInstance(),"startSound",0,"message_popup");
  118.       this.localConv.put(this,"showStarEffect",500,this.day_earnings_str);
  119.       this.localConv.put(this.day_profit_caption,"_visible",0,true);
  120.       this.localConv.put(this.day_profit_str,"_visible",0,true);
  121.       this.localConv.put(this.day_profit_str,"text",0,_loc3_);
  122.       this.localConv.put(this.tip_btn_2,"enabled",0,true);
  123.       this.localConv.put(classes.core.SoundManager.getInstance(),"startSound",0,"message_popup");
  124.       this.localConv.put(this,"showStarEffect",500,this.day_profit_str);
  125.       if(_loc2_ >= 0)
  126.       {
  127.          classes.core.SOManager.getInstance().currentDay = classes.core.SOManager.getInstance().currentDay + 1;
  128.          classes.core.SOManager.getInstance().totalProfit = classes.core.SOManager.getInstance().totalProfit + _loc2_;
  129.          classes.core.SOManager.getInstance().totalScore = classes.core.SOManager.getInstance().totalScore + classes.core.SOManager.getInstance().dayScore;
  130.       }
  131.       this.localConv.put(this.total_profit_caption,"_visible",0,true);
  132.       this.localConv.put(this.total_profit_str,"_visible",0,true);
  133.       this.localConv.put(this.total_profit_str,"text",0,classes.utils.Utils.formattedCurrency(classes.core.SOManager.getInstance().__get__totalProfit()));
  134.       this.localConv.put(this.tip_btn_3,"enabled",0,true);
  135.       this.localConv.put(classes.core.SoundManager.getInstance(),"startSound",0,"message_popup");
  136.       this.localConv.put(this,"showStarEffect",500,this.total_profit_str);
  137.       this.localConv.put(this.total_earnings_caption,"_visible",0,true);
  138.       this.localConv.put(this.total_earnings_str,"_visible",0,true);
  139.       this.localConv.put(this.total_earnings_str,"text",0,classes.utils.Utils.formattedCurrency(classes.core.SOManager.getInstance().__get__totalScore()));
  140.       this.localConv.put(this.tip_btn_4,"enabled",0,true);
  141.       this.localConv.put(classes.core.SoundManager.getInstance(),"startSound",0,"message_popup");
  142.       this.localConv.put(this,"showStarEffect",500,this.total_earnings_str);
  143.       if(_loc2_ < 0)
  144.       {
  145.          this.localConv.put(this.submit_score_btn,"unhide",0);
  146.       }
  147.       if(classes.core.SOManager.getInstance().__get__currentDay() == classes.game.GameData.__get__DAYS_AT_CURRENT_STAGE())
  148.       {
  149.          classes.core.SOManager.getInstance().__set__currentDay(0);
  150.          classes.core.SOManager.getInstance().currentStage = classes.core.SOManager.getInstance().currentStage + 1;
  151.          if(classes.core.SOManager.getInstance().__get__currentStage() == classes.game.GameData.TOTAL_STAGES)
  152.          {
  153.             this.localConv.put(this.continue_btn,"unhide",0);
  154.             classes.core.SOManager.getInstance().__set__gameCompleted(true);
  155.          }
  156.          else
  157.          {
  158.             this.localConv.put(this.next_stage_btn,"unhide",0);
  159.             this.localConv.put(this.upgrades_btn,"unhide",0);
  160.             this.localConv.put(this.main_menu_btn,"unhide",0);
  161.             this.localConv.put(this.progress_saved_caption,"_visible",0,true);
  162.          }
  163.       }
  164.       else
  165.       {
  166.          this.localConv.put(this.next_day_btn,"unhide",0);
  167.          this.localConv.put(this.upgrades_btn,"unhide",0);
  168.          this.localConv.put(this.main_menu_btn,"unhide",0);
  169.          this.localConv.put(this.progress_saved_caption,"_visible",0,true);
  170.       }
  171.    }
  172.    function showStarEffect(tf)
  173.    {
  174.       var _loc3_ = this.getNextHighestDepth();
  175.       var _loc4_ = {_x:tf._x + tf.textWidth / 2,_y:tf._y + tf.textHeight / 2};
  176.       this.attachMovie("star_anim_effect","sae_" + _loc3_,_loc3_,_loc4_);
  177.    }
  178.    function update()
  179.    {
  180.       this.animator.update();
  181.    }
  182.    function dispose()
  183.    {
  184.       this.animator.dispose();
  185.       this.next_day_btn.dispose();
  186.       this.upgrades_btn.dispose();
  187.       this.continue_btn.dispose();
  188.       this.next_stage_btn.dispose();
  189.       this.main_menu_btn.dispose();
  190.       this.submit_score_btn.dispose();
  191.       if(this.upgradeShop)
  192.       {
  193.          this.upgradeShop.dispose();
  194.       }
  195.       super.dispose();
  196.    }
  197. }
  198.